home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Revolution - Das Atari CD Magazin 1997
/
Revolution - Das Atari CD Magazin 1.iso
/
software
/
anwendng
/
qed_397
/
sourcen
/
options.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-01-14
|
33KB
|
1,300 lines
#include "global.h"
#include "av.h"
#include "ausgabe.h"
#include "clipbrd.h"
#include "desktop.h"
#include "disk.h"
#include "edit.h"
#include "error.h"
#include "file.h"
#include "find.h"
#include "fontsel.h"
#include "icon.h"
#include "kurzel.h"
#include "makro.h"
#include "mintlib.h"
#include "obj.h"
#include "printer.h"
#include "projekt.h"
#include "rsc.h"
#include "scroll.h"
#include "se.h"
#include "set.h"
#include "text.h"
#include "version.h"
#include "windows.h"
#include "wp-print.h"
#include "options.h"
LOCAL WORD edobj;
/*
* Autosave
*/
GLOBAL BOOLEAN as_text, as_proj;
GLOBAL BOOLEAN as_text_ask, as_proj_ask;
GLOBAL WORD as_text_min, as_proj_min;
GLOBAL VOID autosave_dial(VOID)
{
UBYTE s[10];
WORD antw;
select_objc(autosave, ASTEXT, as_text);
itoa(as_text_min, s, 10);
objc_setstring(autosave, ASTMIN, s);
select_objc(autosave, ASTASK, as_text_ask);
select_objc(autosave, ASPROJ, as_proj);
itoa(as_proj_min, s, 10);
objc_setstring(autosave, ASPMIN, s);
select_objc(autosave, ASPASK, as_proj_ask);
Arrow_mouse();
antw = HndlDial(autosave, 0, FALSE, NULL, NULL);
Last_mouse();
if (antw == ASOK)
{
as_text = get_select(autosave, ASTEXT);
objc_getstring(autosave, ASTMIN, s);
as_text_min = atoi(s);
if (as_text_min < 1)
as_text_min = 1;
if (as_text_min > 59)
as_text_min = 59;
as_text_ask = get_select(autosave, ASTASK);
as_proj = get_select(autosave, ASPROJ);
objc_getstring(autosave, ASPMIN, s);
as_proj_min = atoi(s);
if (as_proj_min < 1)
as_proj_min = 1;
if (as_proj_min > 59)
as_proj_min = 59;
as_proj_ask = get_select(autosave, ASPASK);
do_all_icon(ALL_TYPES, DO_AUTOSAVE);
}
}
/*
* Globale Optionen
*/
GLOBAL BOOLEAN wish_no_desktop, no_desktop;
GLOBAL BOOLEAN wind_cycle;
GLOBAL WORD cu_mode, cu_width2, cu_high2, transfer_size;
GLOBAL BOOLEAN save_opt, cu_icon, cu_window, cu_width, cu_high,
overwrite, blinking_cursor, ctrl_mark_mode;
GLOBAL PATH helpprog;
LOCAL VOID do_avopen(WINDP window)
{
if (window->handle != DESK)
send_avwinopen(window->handle);
}
LOCAL VOID do_avclose(WINDP window)
{
if (window->handle != DESK)
send_avwinclose(window->handle);
}
GLOBAL VOID global_options(VOID)
{
WORD antw;
UBYTE s[13];
BOOLEAN prev_no_desktop, old_cycle, new_cycle, quit = FALSE;
DIALINFO dial;
FSEL fsel = {"", "*.*"};
PATH n = "", newhelpprog;
prev_no_desktop = no_desktop;
old_cycle = wind_cycle;
select_objc(globalop, OASAVE, save_opt);
select_objc(globalop, ONODESK, wish_no_desktop);
disable_objc(globalop, OCLIP, (scrapdir[0] == EOS));
select_objc(globalop, OCLIP, is_clip_ondisk());
select_objc(globalop, OWINDOW, wind_cycle);
select_objc(globalop, OBLINK, blinking_cursor);
select_objc(globalop, OEXTFONT, extern_fontselect);
select_objc(globalop, OCTRL, ctrl_mark_mode);
itoa(transfer_size,s,10);
objc_setstring(globalop, OTRANS, s);
if (helpprog[0] != EOS)
file_name(helpprog, s, FALSE);
else
strcpy(s, "");
objc_setstring(globalop, OHELPNAME, s);
strcpy(newhelpprog, helpprog);
Arrow_mouse();
open_dial(globalop, FALSE, NULL, &dial);
dial_draw(&dial);
edobj = OTRANS;
do
{
antw = dial_do(&dial, &edobj) & 0x7FFF;
switch (antw)
{
case OHELP :
close_dial(FALSE, NULL, &dial);
if (helpprog[0] != EOS)
{
set_fsel_path(helpprog);
file_name(helpprog, n, FALSE);
}
strcpy(fsel.name, n);
if (select_file(&fsel, n, STRING(FINDHPSTR)))
{
strcpy(newhelpprog, n);
file_name(newhelpprog, n, FALSE);
objc_setstring(globalop, OHELPNAME, n);
}
open_dial(globalop, FALSE, NULL, &dial);
select_objc(globalop, antw, FALSE);
dial_draw(&dial);
break;
default:
quit = TRUE;
break;
}
}
while (!quit);
select_objc(globalop, antw, FALSE);
dial_end(&dial);
if (antw == GOOK)
{
save_opt = get_select(globalop, OASAVE);
wish_no_desktop = get_select(globalop, ONODESK);
if (scrapdir[0]!=EOS)
clip_ondisk(get_select(globalop, OCLIP));
new_cycle = get_select(globalop, OWINDOW);
if (old_cycle && !new_cycle) /* war an, nun aus */
{
get_all_windows(NIL, SRCH_OPENED, do_avclose);
wind_cycle = new_cycle;
}
if (new_cycle && !old_cycle) /* nun an, war aus */
{
wind_cycle = new_cycle;
get_all_windows(NIL, SRCH_OPENED, do_avopen);
}
blinking_cursor = get_select(globalop, OBLINK);
extern_fontselect = get_select(globalop, OEXTFONT);
ctrl_mark_mode = get_select(globalop, OCTRL);
objc_getstring (globalop, OTRANS, s);
transfer_size = atoi(s);
if (transfer_size == 0)
transfer_size = 1;
strcpy(helpprog, newhelpprog);
if (prev_no_desktop != wish_no_desktop)
note(1, DESKCHG);
}
Last_mouse();
} /* mglobalop */
/*
* Lokale Optionen
*/
GLOBAL UBYTE muster_str[MUSTER_ANZ][MUSTER_LEN+1];
GLOBAL LOCAL_OPT loc_opt[MUSTER_ANZ];
GLOBAL WORD loc_opt_anz;
LOCAL WORD local_option;
LOCAL BOOLEAN krz_changed = FALSE;
LOCAL WORD selected_muster;
LOCAL LOCAL_OPT bak_loc_opt[MUSTER_ANZ];
LOCAL UBYTE bak_muster_str[MUSTER_ANZ][MUSTER_LEN+1];
LOCAL VOID option_fill(VOID)
{
UBYTE s[10], str[13] = "";
LOC_OPTP lo;
lo = &loc_opt[local_option];
select_objc(localop, OTAB, lo->tab);
itoa(lo->tabsize,s,10);
objc_setstring(localop, OTABSIZE, s);
select_objc(localop, OEINRUCK, lo->einruecken);
objc_setstring(localop, OWORT, lo->wort_str);
select_objc(localop, OUMBRUCH, lo->umbrechen);
select_objc(localop, OFORMLOAD, lo->format_by_load);
select_objc(localop, OFORMPASTE, lo->format_by_paste);
objc_setstring(localop, OUMBTEXT, lo->umbruch_str);
itoa(lo->lineal_len,s,10);
select_objc(localop, OBACKUP, lo->backup);
objc_setstring(localop, OEXT, lo->backup_ext);
objc_setstring(localop, OLINEAL, s);
if (lo->kurzel[0] != EOS)
file_name(lo->kurzel, str, FALSE);
else
strcpy(str, STRING(KURZELSTR));
fill_ptext(localop, OKURZELNAME, str);
select_objc(localop, OSHOWEND, lo->show_end);
}
LOCAL VOID option_get(VOID)
{
UBYTE s[20];
WORD help;
LOC_OPTP lo;
lo = &loc_opt[local_option];
lo->tab = get_select(localop, OTAB);
objc_getstring (localop, OTABSIZE, s);
if (*s)
{
help = atoi(s);
if (help < 1 || help > 50)
help = 3;
}
else
help = 3;
lo->tabsize = help;
lo->umbrechen = get_select(localop, OUMBRUCH);
lo->einruecken = get_select(localop, OEINRUCK);
objc_getstring(localop, OUMBTEXT, lo->umbruch_str);
str2set(lo->umbruch_str,lo->umbruch_set);
lo->format_by_load = get_select(localop, OFORMLOAD);
lo->format_by_paste = get_select(localop, OFORMPASTE);
lo->backup = get_select(localop, OBACKUP);
objc_getstring(localop, OEXT, lo->backup_ext);
objc_getstring(localop, OLINEAL, s);
if (*s)
{
help = atoi(s);
if (help < 3 || help > 200) help = 65;
}
else
help = 65;
lo->lineal_len = help;
objc_getstring(localop, OWORT, lo->wort_str);
str2set(lo->wort_str,lo->wort_set);
lo->show_end = get_select(localop, OSHOWEND);
}
LOCAL BOOLEAN option_changed(VOID)
{
UBYTE s[40];
WORD help;
LOC_OPTP lo;
lo = &loc_opt[local_option];
if (lo->tab != get_select(localop, OTAB)) return TRUE;
objc_getstring (localop, OTABSIZE, s);
if (*s)
{
help = atoi(s);
if (help<1 || help>50) help = 3;
}
else
help = 3;
if (lo->tabsize != help)
return TRUE;
if (lo->umbrechen != get_select(localop, OUMBRUCH))
return TRUE;
if (lo->einruecken != get_select(localop, OEINRUCK))
return TRUE;
objc_getstring(localop, OUMBTEXT, s);
if (strcmp(lo->umbruch_str,s))
return TRUE;
str2set(lo->umbruch_str,lo->umbruch_set);
if (lo->format_by_load != get_select(localop, OFORMLOAD))
return TRUE;
if (lo->format_by_paste != get_select(localop, OFORMPASTE))
return TRUE;
objc_getstring(localop, OLINEAL, s);
if (*s)
{
help = atoi(s);
if (help<3 || help>200) help = 65;
}
else
help = 65;
if (lo->lineal_len != help)
return TRUE;
objc_getstring(localop, OWORT, s);
if (strcmp(lo->wort_str,s))
return TRUE;
str2set(lo->wort_str,lo->wort_set);
objc_getstring(localop, OEXT, s);
if (strcmp(lo->backup_ext, s))
return TRUE;
if (lo->backup != get_select(localop, OBACKUP))
return TRUE;
if (krz_changed)
{
krz_changed = FALSE;
return TRUE;
}
if (lo->show_end != get_select(localop, OSHOWEND))
return TRUE;
return FALSE;
}
LOCAL VOID config_muster(VOID)
{
DIALINFO dial;
BOOLEAN quit = FALSE;
WORD i, antw;
UBYTE str[MUSTER_LEN+1];
if (option_changed() && note(1,APPLAYCH)==2)
return;
option_get();
/* Daten für Abbruch retten */
COPYW(bak_loc_opt, loc_opt, (short) sizeof(LOCAL_OPT) * MUSTER_ANZ);
COPYW(bak_muster_str, muster_str, MUSTER_ANZ * (MUSTER_LEN+1));
selected_muster = -1;
disable_objc(muster, DMDELETE, TRUE);
disable_objc(muster, DMCHANGE, TRUE);
disable_objc(muster, DMNEW, (loc_opt_anz == MUSTER_ANZ));
for (i=1; i<loc_opt_anz; i++)
{
objc_setstring(muster, DM1 + i - 1, muster_str[i]);
do_flags(muster, DM1 + i - 1, SELECTABLE);
}
for (; i<MUSTER_ANZ; i++)
{
objc_setstring(muster,DM1 + i - 1, STRING(FREESTR));
disable_objc(muster, DM1 + i - 1, TRUE);
}
open_dial(muster, FALSE, NULL, &dial);
dial_draw(&dial);
do
{
antw = dial_do(&dial, NULL) & 0x7FFF;
if (antw >= DM1 && antw <= DM9)
{
if (antw == selected_muster)
{
select_objc(muster, selected_muster, FALSE);
selected_muster = -1;
disable_objc(muster, DMNEW, FALSE);
disable_objc(muster, DMDELETE, TRUE);
disable_objc(muster, DMCHANGE, TRUE);
}
else
{
select_objc(muster, selected_muster, FALSE);
selected_muster = antw;
select_objc(muster, selected_muster, TRUE);
disable_objc(muster, DMNEW, TRUE);
disable_objc(muster, DMDELETE, FALSE);
disable_objc(muster, DMCHANGE, FALSE);
}
dial_draw(&dial);
}
else
{
switch (antw)
{
case DMNEW: /* Neues Dateimuster eingeben */
objc_setstring(musterchg, DMCTEXT, "");
if (HndlDial(musterchg, 0, FALSE, NULL, NULL) == DMCOK)
{
WORD i;
i = loc_opt_anz;
if (i < MUSTER_ANZ)
{
objc_getstring(musterchg, DMCTEXT, str);
objc_setstring(muster, DM1 + i - 1, str);
disable_objc(muster, DM1 + i - 1, FALSE);
strcpy(muster_str[i],str);
COPYW(&loc_opt[i], &loc_opt[0], (short) sizeof(LOCAL_OPT));
loc_opt_anz++;
draw_Objc(muster, DMEXTBOX, 8);
}
}
if (loc_opt_anz == MUSTER_ANZ) /* wenn voll, Button aus! */
{
disable_objc(muster, DMNEW, TRUE);
draw_Objc(muster, DMNEW, 1);
}
break;
case DMDELETE: /* Muster löschen */
i = selected_muster - DM1 + 1;
if (i == local_option) /* aktuelles Muster gelöscht! */
local_option = 0;
COPYW(&loc_opt[i], &loc_opt[i+1], (short) sizeof(LOCAL_OPT) * (loc_opt_anz-i-1));
COPYW(&muster_str[i], &muster_str[i+1], (MUSTER_LEN+1) * (loc_opt_anz-i-1));
loc_opt_anz--;
for (; i<loc_opt_anz; i++)
objc_setstring(muster, DM1 + i - 1, muster_str[i]);
if (i < MUSTER_ANZ)
{
objc_setstring(muster, DM1 + i - 1, STRING(FREESTR));
disable_objc(muster, DM1 + i - 1, TRUE);
}
select_objc(muster, selected_muster, FALSE);
selected_muster = -1;
disable_objc(muster, DMDELETE, TRUE);
disable_objc(muster, DMCHANGE, TRUE);
if (loc_opt_anz < MUSTER_ANZ) /* wieder welche frei? */
disable_objc(muster, DMNEW, FALSE);
dial_draw(&dial);
break;
case DMCHANGE: /* Muster ändern */
objc_getstring(muster, selected_muster, str);
objc_setstring(musterchg, DMCTEXT, str);
if (HndlDial(musterchg, 0, FALSE, NULL, NULL) == DMCOK)
{
objc_getstring(musterchg, DMCTEXT, str);
objc_setstring(muster, selected_muster, str);
draw_Objc(muster, DMEXTBOX, 8);
strcpy(muster_str[selected_muster - DM1 + 1], str);
}
break;
default:
quit = TRUE;
break;
} /* switch */
select_objc(muster, antw, FALSE);
draw_Objc(muster, antw, 1);
} /* if */
} /* while */
while (!quit);
dial_end(&dial);
disable_objc(localop, OTYPECIRC, (loc_opt_anz <= 1));
if (antw == DMOK)
{
if (muster_str[local_option][0]==EOS)
{
local_option = 0;
option_fill();
}
draw_Objc(localop, OTYPE, 1);
draw_Objc(localop, OBOX, 8);
}
else
{
COPYW(loc_opt,bak_loc_opt, (short) sizeof(LOCAL_OPT) * MUSTER_ANZ);
COPYW(muster_str, bak_muster_str, MUSTER_ANZ * (MUSTER_LEN + 1));
}
if (selected_muster!=-1)
select_objc(muster, selected_muster, FALSE);
}
LOCAL BOOLEAN build_popup(POPUP_STRUK *pop)
{
UBYTE str[MUSTER_LEN + 1];
WORD i;
if (loc_opt_anz <= 1)
return FALSE;
strcpy(str, " ");
strcat(str, muster_str[0]);
for (i = (WORD)strlen(str); i < MUSTER_LEN; i++)
strcat(str, " ");
create_popup(pop, MUSTER_ANZ, POPUPSTRG, str);
for (i = 1; i < loc_opt_anz; i++)
{
strcpy(str, " ");
strcat(str, muster_str[i]);
append_popup(pop, POPUPSTRG, str);
}
if (pop->tree != NULL)
{
for(i = 0; i < pop->akt_item + 2; i++)
xrsrc_obfix(pop->tree, i);
dial_fix(pop->tree);
return TRUE;
}
return FALSE;
}
GLOBAL VOID local_options(VOID)
{
WORD antw, y;
WINDP window;
PATH save_name;
DIALINFO dial;
BOOLEAN quit = FALSE, doppel_klick;
FSEL fsel = {"", "*.KRZ"};
PATH name = "";
UBYTE str[MUSTER_LEN + 1] = " ";
POPUP_STRUK pop;
local_option = 0;
window = top();
if (window->flags & WI_FONTSIZE)
{
TEXTP t_ptr = get_text(window->link);
local_option = (short)(t_ptr->loc_opt - loc_opt);
strcat(str, muster_str[local_option]);
}
/* Sonderbehandlung für '*'-Eintrag, damit das Popup klappt! */
if (local_option == 0)
strcpy(str, " * ");
objc_setstring(localop, OTYPE, str);
option_fill();
strcpy(save_name, loc_opt[local_option].kurzel);
disable_objc(localop, OTYPECIRC, (loc_opt_anz <= 1));
Arrow_mouse();
open_dial(localop, FALSE, NULL, &dial);
dial_draw(&dial);
do
{
antw = dial_do(&dial, NULL);
doppel_klick = (antw&0x8000);
antw &= 0x7FFF;
switch (antw)
{
case OTYPESTR :
case OTYPECIRC :
case OTYPE :
if (doppel_klick && antw == OTYPE)
{
config_muster();
option_fill();
dial_draw(&dial);
}
else if (build_popup(&pop))
{
if (antw == OTYPECIRC)
y = popup_select(NIL, localop, OTYPE, pop.tree, 1, FALSE, DO_CYCLE, NULL, (POP_CB)NULL);
else
y = popup_select(NIL, localop, OTYPE, pop.tree, 1, FALSE, DO_POPUP, NULL, (POP_CB)NULL);
y -= pop.first_item;
if (y >= 0 && y != local_option)
{
if (option_changed() && note(1,APPLAYCH) == 1)
option_get();
local_option = y;
option_fill();
draw_Objc(localop, OBOX, MAX_DEPTH);
}
free_popup(&pop);
}
break;
case OKURZEL:
if (doppel_klick)
{
strcpy(loc_opt[local_option].kurzel, "");
krz_changed = TRUE;
fill_ptext(localop, OKURZELNAME, STRING(KURZELSTR));
draw_Objc(localop, OKURZELNAME, 1);
}
else
{
close_dial(FALSE, NULL, &dial);
if (loc_opt[local_option].kurzel[0] != EOS)
{
set_fsel_path(loc_opt[local_option].kurzel);
file_name(loc_opt[local_option].kurzel, name, FALSE);
}
strcpy(fsel.name, name);
if (select_file(&fsel, name, STRING(FINDKURZELSTR)))
{
strcpy(loc_opt[local_option].kurzel, name);
file_name(name, str, FALSE);
krz_changed = TRUE;
objc_setstring(localop, OKURZELNAME, str);
}
open_dial(localop, FALSE, NULL, &dial);
select_objc(localop, OKURZEL, FALSE);
dial_draw(&dial);
}
break;
case OOK:
quit = TRUE;
break;
case ORAUS :
quit = TRUE;
break;
}
select_objc(localop, antw, FALSE);
draw_Objc(localop, antw, 1);
}
while (!quit);
dial_end(&dial);
if (antw == OOK)
{
option_get();
update_loc_opt();
absatz_edit();
ch_kurzel(loc_opt[local_option].kurzel, TRUE);
}
else
strcpy(loc_opt[local_option].kurzel, save_name);
Last_mouse();
} /* local_option */
/*
* Defaulteinstellungen
*/
VOID init_default_var(VOID)
{
WORD i;
time_t t;
s_grkl = FALSE;
s_runter = TRUE;
s_global = TRUE;
s_quant = FALSE;
s_wort = FALSE;
s_round = FALSE;
df_rekursiv= FALSE;
r_modus = RP_FIRST;
s_str[0] = EOS;
r_str[0] = EOS;
df_name[0] = EOS;
for (i = HIST_ANZ; (--i)>=0; s_history[i][0]=EOS)
;
rp_box_x = 0;
rp_box_y = 0;
cu_window = FALSE;
cu_icon = FALSE;
cu_width = FALSE;
cu_high = FALSE;
cu_mode = 0;
cu_width2 = 80;
cu_high2 = 20;
use_gdos_print = FALSE;
vorschub = TRUE;
zeilen_nr = FALSE;
seiten_nr = FALSE;
rand_len = 2;
use_rand = TRUE;
print_block = 0;
wp_mode = PICA;
wp_treiber[0] = EOS;
wp_nlq = FALSE;
wp_seiten_len = 65;
wp_seiten_width = 80;
metafile[0] = EOS;
save_opt = FALSE;
wind_cycle = FALSE;
clip_ondisk(FALSE);
wish_no_desktop = no_desktop = FALSE;
overwrite = FALSE;
transfer_size = 100;
helpprog[0] = EOS;
blinking_cursor = FALSE;
extern_fontselect = FALSE;
ctrl_mark_mode = FALSE;
for (i = 0; i < 3; i++)
error[i][0] = EOS;
for (i=MUSTER_ANZ; (--i)>=1; muster_str[i][0]=EOS) ;
strcpy(muster_str[0],"*"); /* Bleibt konstant */
loc_opt[0].tab = TRUE;
loc_opt[0].tabsize = 3;
loc_opt[0].einruecken = TRUE;
strcpy(loc_opt[0].wort_str,"A-Za-zäöüßÄÖÜ0-9");
str2set(loc_opt[0].wort_str,loc_opt[0].wort_set);
loc_opt[0].umbrechen = FALSE;
loc_opt[0].format_by_load = FALSE;
loc_opt[0].format_by_paste = FALSE;
strcpy(loc_opt[0].umbruch_str,"- \t");
str2set(loc_opt[0].umbruch_str,loc_opt[0].umbruch_set);
loc_opt[0].lineal_len = 70;
loc_opt_anz = 1;
strcpy(loc_opt[0].backup_ext, "BAK");
loc_opt[0].backup = FALSE;
loc_opt[0].show_end = FALSE;
se_autosave = FALSE;
se_autosearch = FALSE;
for (i = 0; i < SHELLANZ; i++)
{
se_shells[i].Name[0] = EOS;
se_shells[i].Makefile[0] = EOS;
}
umlaut_from = 0;
umlaut_to = 0;
as_text = FALSE;
as_text_min = 0;
as_text_ask = FALSE;
as_proj = FALSE;
as_proj_min = 0;
as_proj_ask = FALSE;
time(&t);
local_time = localtime(&t);
}
/*
* Datei
*/
LOCAL FSEL qed_fsel = {"DEFAULT.QED","*.QED"};
LOCAL RING tmp_ring;
LOCAL VOID read_opt(const UBYTE *format, UBYTE *str, ...)
{
va_list ptr;
WORD *i;
LONG *l;
UBYTE *s;
va_start(ptr,str);
s = strchr(str,'@');
while(*format!=EOS)
{
if (s==NULL)
{
switch (*format++)
{
case 'i': i = va_arg(ptr,WORD*);
*i = 0;
break;
case 'l': l = va_arg(ptr,LONG*);
*l = 0L;
break;
case 's': strcpy(va_arg(ptr,UBYTE*),"");
break;
}
}
else
{
str = s+1;
s = strchr(str,'@');
if (s!=NULL) *s = EOS;
switch (*format++)
{
case 'i': i = va_arg(ptr,WORD*);
*i = atoi(str);
break;
case 'l': l = va_arg(ptr,LONG*);
*l = atol(str);
break;
case 's': strcpy(va_arg(ptr,UBYTE*),str);
break;
}
}
}
va_end(ptr);
}
GLOBAL WORD option_load (VOID)
{
LineEnding ending;
RING t;
if (qed_path[0]==EOS)
{
PATH name;
if (!select_file (&qed_fsel, name, STRING(LOADSETUPSTR)))
{
init_default_var();
return 0;
}
make_ext(name, "qed");
strcpy(qed_path, name);
}
else
file_name(qed_path, qed_fsel.name, FALSE);
init_textring(&t);
if (load_datei(qed_path, &t, FALSE, &ending) == 0)
{
LOC_OPTP lo;
WORD opt, opt2, i, l, x, y, version, muster_nr;
BOOLEAN bool, out_of_date;
RECT r;
LONG anz, line;
LINEP lauf;
UBYTE *str, s[40], s2[40], s3[40], s4[40], *c;
PATH p;
CICONBLK *cicon;
Busy_mouse();
muster_nr = 0;
anz = 0;
lauf = FIRST(&t);
str = TEXT(lauf);
if (*str++ == '#' && *str ++ == 'V')
{
read_opt("si", str, s, &version);
out_of_date = (version < ParameterVersion);
if ((strcmp(s, "qed.INF") == 0))
{
NEXT(lauf);
anz = t.lines-1;
}
}
if ((out_of_date) || (anz <= 0))
{
i = note(1, WRONGINF);
if (i == 1)
{
init_default_var();
Last_mouse();
return 0;
}
}
while ((--anz) >= 0)
{
if (lauf->len > 3 && TEXT(lauf)[0] == '#')
{
str = TEXT(lauf) + 1;
switch(*str++)
{
case 'A' :
read_opt("iiiiii", str,
&as_text, &as_text_min, &as_text_ask,
&as_proj, &as_proj_min, &as_proj_ask);
break;
case 'D' :
read_opt("iiiiiiss", str, &opt, &rand_len, &gdos_device, &wp_seiten_len,
&wp_seiten_width, &wp_mode, wp_treiber, metafile);
zeilen_nr = (opt & 1); opt >>= 1;
seiten_nr = (opt & 1); opt >>= 1;
vorschub = (opt & 1); opt >>= 1;
pruef_prn = (opt & 1); opt >>= 1;
use_rand = (opt & 1); opt >>= 1;
use_gdos_print= (opt & 1); opt >>= 1;
wp_nlq = (opt & 1); opt >>= 1;
break;
case 'F' :
set_makro_str(str + 1);
break;
case 'G' :
read_opt("iiiii",str, &opt, &cu_mode, &cu_width2, &cu_high2,
&transfer_size);
if (transfer_size == 0)
transfer_size = 100;
save_opt = (opt & 1); opt >>= 1;
no_desktop= (opt & 1); opt >>= 1;
wish_no_desktop = no_desktop;
clip_ondisk((opt & 1)); opt >>= 1;
wind_cycle= (opt & 1); opt >>= 1;
blinking_cursor = (opt & 1); opt >>= 1;
extern_fontselect = (opt & 1); opt >>= 1;
overwrite = (opt & 1); opt >>= 1;
cu_icon = (opt & 1); opt >>= 1;
cu_window = (opt & 1); opt >>= 1;
cu_width = (opt & 1); opt >>= 1;
cu_high = (opt & 1); opt >>= 1;
ctrl_mark_mode = (opt & 1); opt >>= 1;
/* frei opt >>= 1; */
/* frei opt >>= 1; */
/* frei opt >>= 1; */
/* frei opt >>= 1; */
break;
case 'H' :
read_opt("s", str, s);
for (i = 0; i < HIST_ANZ; i++)
if (s_history[i][0] == EOS)
break;
if (i < HIST_ANZ)
strcpy(s_history[i], s);
break;
case 'I' :
read_opt("iii",str, &i, &x, &y);
switch (i)
{
case 0 : /* F-Tasten */
add_icon_to_desk(0, NULL, x, y);
break;
case 2 : /* PRINTER */
cicon = (CICONBLK *)get_obspec(icons, IPRINTER);
iprinter = add_icon_to_desk(IPRINTER, cicon->monoblk.ib_ptext, x, y);
add_icon(printer_type, iprinter);
break;
case 3 : /* DISK */
cicon = (CICONBLK *)get_obspec(icons, IDISK);
idisk = add_icon_to_desk(IDISK, cicon->monoblk.ib_ptext, x, y);
add_icon(disk_type, idisk);
break;
}
break;
case 'L' :
read_opt("siiissss",str, s, &opt, &i, &l, s2, s3, p, s4);
if (muster_nr < MUSTER_ANZ)
{
if (muster_nr > 0)
strcpy(muster_str[muster_nr], s);
lo = &loc_opt[muster_nr];
lo->tab = (opt & 1); opt >>= 1;
lo->einruecken = (opt & 1); opt >>= 1;
lo->umbrechen = (opt & 1); opt >>= 1;
lo->format_by_load = (opt & 1); opt >>= 1;
lo->format_by_paste = (opt & 1); opt >>= 1;
lo->backup = (opt & 1); opt >>= 1;
lo->show_end = (opt & 1); opt >>= 1;
lo->tabsize = i;
lo->lineal_len = l;
strcpy(lo->umbruch_str, s2);
str2set(lo->umbruch_str, lo->umbruch_set);
strcpy(lo->wort_str, s3);
str2set(lo->wort_str,lo->wort_set);
strcpy(lo->kurzel, p);
strcpy(lo->backup_ext, s4);
muster_nr++;
}
break;
case 'M' :
read_opt("issli",str, &i, s, p, &line, &x);
set_marke(i, s, p, line, x);
break;
case 'O' :
read_opt("s", str, p);
add_diskinfo(p, TRUE);
break;
case 'P' :
read_opt("sssss", str, helpprog, error[0], def_prj_path, error[1], error[2]);
c = getenv("STGUIDE");
if ((helpprog[0] == EOS) && (c != NULL))
strcpy(helpprog, c);
set_def_prj();
break;
case 'R' :
read_opt("iisssiiii", str, &opt, &r_modus, s_str, r_str, df_name,
¨aut_from, ¨aut_to, &rp_box_x, &rp_box_y);
s_round = (opt & 1); opt >>= 1;
s_quant = (opt & 1); opt >>= 1;
s_grkl = (opt & 1); opt >>= 1;
s_runter = (opt & 1); opt >>= 1;
s_global = (opt & 1); opt >>= 1;
df_rekursiv = (opt & 1); opt >>= 1;
s_wort = (opt & 1); opt >>= 1;
break;
case 'S' :
read_opt("isiis", str, &i, s, &opt, &opt2, p);
strcpy(se_shells[i].Name, s);
strcpy(se_shells[i].Makefile, p);
se_autosave = (opt == 1);
se_autosearch = (opt2 == 1);
/*
SE_Shells[i].aktiv = (opt == 1);
SE_Shells[i].start_comm = (opt2 == 1);
*/
break;
case 'W' :
read_opt("iiiiiiii", str, &i, &r.x, &r.y, &r.w, &r.h, &opt, &opt2, &bool);
add_windinfo(i, &r, opt, opt2, bool);
break;
case 'Z' :
read_opt("iiii",str, &winFont.ID, &winFont.Size, &druckFont.ID, &druckFont.Size);
font_change();
break;
}
}
NEXT(lauf);
}
loc_opt_anz = max(1, muster_nr);
kill_textring(&t);
Last_mouse();
return 0;
}
else
{
kill_textring(&t);
return 1;
}
}
LOCAL VOID write_opt(UBYTE* format, ...)
{
UBYTE str[200], help[20];
va_list ptr;
LINEP col;
va_start(ptr,format);
str[0] = '#';
str[1] = *format++;
str[2] = EOS;
while(*format!=EOS)
{
strcat(str,"@");
switch(*format++)
{
case 'i' : itoa(va_arg(ptr,WORD),help,10);
strcat(str,help);
break;
case 'l' : ltoa(va_arg(ptr,LONG),help,10);
strcat(str,help);
break;
case 's' : strcat(str,va_arg(ptr,UBYTE*));
break;
}
}
va_end(ptr);
col = new_col_w(str, (short)strlen(str));
col_append(&tmp_ring, col);
}
LOCAL VOID get_wind_data(WINDP window)
{
if (window->flags & WI_ICONIFIED)
uniconify_window(window, NULL);
if (window->class == CLASS_CLIP)
{
if (window->opened)
write_opt("Os", "-C");
}
if (window->class == CLASS_EDIT || window->class == CLASS_PROJEKT)
{
TEXTP t_ptr = get_text(window->link);
UBYTE str[256], str2[256];
WORD i, j;
BOOLEAN quoting = FALSE;
if (!t_ptr->namenlos)
{
i = 0;
j = 0;
while (i < strlen(t_ptr->filename))
{
str[j++] = t_ptr->filename[i];
if (t_ptr->filename[i] == '\'') /* gibts ' im Namen? */
{
str[j++] = '\'';
quoting = TRUE;
}
if (t_ptr->filename[i] == ' ') /* oder Blank? */
quoting = TRUE;
i++;
}
str[j] = EOS;
if (quoting)
sprintf(str2, "\'%s\'", str);
else
strcpy(str2, str);
strcat(str2," ");
ltoa(t_ptr->ypos + 1, str, 10);
strcat(str2, str);
strcat(str2, " ");
ltoa(BildPos(t_ptr->xpos,t_ptr->cursor_line,t_ptr->loc_opt->tab,t_ptr->loc_opt->tabsize)+1, str, 10);
strcat(str2, str);
/*
* Als Text geöffnete Projekte:
*/
if (window->class == CLASS_EDIT && filematch(t_ptr->filename, "*.QPJ"))
strcat(str2, " -p ");
if (!window->opened)
strcat(str2," -o");
write_opt("Os", str2);
}
}
}
GLOBAL WORD option_save(BOOLEAN interactiv)
{
LOC_OPTP lo;
LONG line;
WORD x, y, i, d, opt, opt2;
PATH file;
WORD used, antw;
RECT r;
UBYTE str[256], *p;
FILENAME name;
if (interactiv)
{
if (qed_path[0] == EOS)
get_path(qed_path, 0);
if (caseSens(qed_path, NULL))
strcpy(qed_fsel.suffix, "*.qed");
else
strcpy(qed_fsel.suffix, "*.QED");
set_fsel_path(qed_path);
if (!select_file (&qed_fsel, file, STRING(SAVESETUPSTR)))
return 0;
p = strrchr(file, '.');
if ((p == NULL) || ((strcmp(p+1, "qed") != 0) && (strcmp(p+1, "QED") != 0)))
make_ext(file, "qed");
strcpy(qed_path, file);
}
init_textring(&tmp_ring);
/*
* Bisher vergebene Zeilen-Kennungen (3.70) :
*
* A Autosave
* D Druckerparameter
* F Funktionstasten
* G globale Parameter
* H History Suchbegriffe
* I Standard-Icons
* L Lokale Parameter
* M Marken
* O Offene Dateien
* P Diverse Pfade und Texte
* R Suchen/Ersetzen
* S SE-Protokoll
* V Versionsnummer
* W Fensterpositionen
* Z Zeichensätze
*/
/* Version */
write_opt("Vsi", "qed.INF", ParameterVersion);
/* Autosave */
write_opt("Aiiiiii", as_text, as_text_min, as_text_ask,
as_proj, as_proj_min, as_proj_ask);
/* Drucker */
opt = 0;
if (zeilen_nr) opt += 1;
if (seiten_nr) opt += 2;
if (vorschub) opt += 4;
if (pruef_prn) opt += 8;
if (use_rand) opt += 16;
if (use_gdos_print) opt += 32;
if (wp_nlq) opt += 64;
write_opt("Diiiiiiss", opt, rand_len, gdos_device, wp_seiten_len, wp_seiten_width,
wp_mode, wp_treiber, metafile);
/* Funktionstasten */
i = -1;
while(get_makro_str(&i, str))
write_opt("Fs", str);
/* Globales */
opt = 0;
if (save_opt) opt += 1;
if (wish_no_desktop) opt += 2;
if (is_clip_ondisk()) opt += 4;
if (wind_cycle) opt += 8;
if (blinking_cursor) opt += 16;
if (extern_fontselect) opt += 32;
if (overwrite) opt += 64; /* Schreibmodus */
if (cu_icon) opt += 128; /* Aufräumen */
if (cu_window) opt += 256;
if (cu_width) opt += 512;
if (cu_high) opt += 1024;
if (ctrl_mark_mode) opt += 2048;
/* frei opt += 4096; */
/* frei opt += 8192; */
/* frei opt += 16384: */
/* frei opt += 32768; */
write_opt("Giiiii", opt, cu_mode, cu_width2, cu_high2, transfer_size);
/* History Suchbegriffe */
for (i=0; i<HIST_ANZ; i++)
{
if (s_history[i][0]==EOS) break;
write_opt("Hs", s_history[i]);
}
/* Icons ohne Fenster */
get_icon_pos(idisk, &x, &y);
write_opt("Iiii", 3, x, y);
get_icon_pos(iprinter, &x, &y);
write_opt("Iiii", 2, x, y);
get_icon_pos(0, &x, &y); /* F-Tasten */
write_opt("Iiii", 0, x, y);
/* Lokales */
for (i = 0; i < loc_opt_anz; i++)
{
lo = &loc_opt[i];
opt = 0;
if (lo->tab) opt += 1;
if (lo->einruecken) opt += 2;
if (lo->umbrechen) opt += 4;
if (lo->format_by_load) opt += 8;
if (lo->format_by_paste) opt += 16;
if (lo->backup) opt += 32;
if (lo->show_end) opt += 64;
write_opt("Lsiiissss", muster_str[i], opt, lo->tabsize, lo->lineal_len,
lo->umbruch_str,lo->wort_str, lo->kurzel, lo->backup_ext);
}
/* Marken */
for (i = 0; i < 5; i++)
{
get_marke(i, name, file, &line, &x);
if (file[0] != EOS)
write_opt("Missli", i, name, file, line, x);
}
/* geladene Dateien */
get_all_windows(NIL, SRCH_ANY, get_wind_data);
/* Diverse Pfade und Texte */
write_opt("Psssss", helpprog, error[0], def_prj_path, error[1], error[2]);
/* Suchen/Ersetzen */
opt = 0;
if (s_round) opt += 1;
if (s_quant) opt += 2;
if (s_grkl) opt += 4;
if (s_runter) opt += 8;
if (s_global) opt += 16;
if (df_rekursiv) opt += 32;
if (s_wort) opt += 64;
write_opt("Riisssiiii", opt, r_modus, s_str, r_str, df_name, umlaut_from,
umlaut_to, rp_box_x, rp_box_y);
/* SE-Protokol */
for (i = 0; i < SHELLANZ - 1; i++)
{
if (se_shells[i].Name[0] != EOS)
write_opt("Sisiis", i, se_shells[i].Name, se_autosave,
se_autosearch, se_shells[i].Makefile);
/*
write_opt("Sisiis", i, SE_Shells[i].Name, SE_Shells[i].aktiv,
SE_Shells[i].start_comm, SE_Shells[i].Makefile);
*/
}
/* Fenstergröße und Iconposition */
d = -1;
while(get_windinfo(&d, &i, &r, &opt, &opt2, &used))
write_opt("Wiiiiiiii", i, r.x, r.y, r.w, r.h, opt, opt2, used);
/* Zeichensätze */
write_opt("Ziiii", winFont.ID, winFont.Size, druckFont.ID, druckFont.Size);
/* Ring anpassen: Leerzeile vom init entfernen */
col_delete(tmp_ring.head.nachf);
tmp_ring.lines--;
/* und wechschreiben */
antw = save_datei(qed_path, &tmp_ring, FALSE, tos);
kill_textring(&tmp_ring);
return antw;
}